# app/api/upload/schemas.py

from typing import List, Dict, Any, Optional
from pydantic import BaseModel, Field

class UploadResponse(BaseModel):
    """上传响应模型"""
    task_id: str = Field(..., description="任务ID")
    message: str = Field(..., description="响应消息")
    status: str = Field(..., description="任务状态")
    knowledge_base: str = Field(..., description="知识库名称")

class KnowledgeBaseInfo(BaseModel):
    """知识库信息模型"""
    name: str = Field(..., description="知识库名称")
    description: str = Field("", description="知识库描述")
    file_count: int = Field(0, description="文件数量")
    created_time: str = Field("", description="创建时间")
    last_updated: str = Field("", description="最后更新时间")

class TaskStatusResponse(BaseModel):
    """任务状态响应模型"""
    task_id: str = Field(..., description="任务ID")
    status: str = Field(..., description="任务状态")
    progress: int = Field(..., description="处理进度(0-100)")
    message: str = Field(..., description="状态消息")
    file_path: Optional[str] = Field(None, description="文件路径")
    file_type: Optional[str] = Field(None, description="文件类型")
    knowledge_base: Optional[str] = Field(None, description="知识库名称")
    text_chunks_count: Optional[int] = Field(None, description="文本块数量")
    images_count: Optional[int] = Field(None, description="图片数量")
    processing_time: Optional[float] = Field(None, description="处理时间(秒)")
    error: Optional[str] = Field(None, description="错误信息")
    result: Optional[Dict[str, Any]] = Field(None, description="处理结果")
    oss_url: Optional[str] = Field(None, description="OSS文件URL")
    oss_success: Optional[bool] = Field(None, description="OSS上传是否成功")

class BatchUploadRequest(BaseModel):
    """批量上传请求模型"""
    file_paths: List[str] = Field(..., description="文件路径列表")
    description: str = Field("", description="上传描述")
    knowledge_base: str = Field("default", description="知识库名称")

class FileInfo(BaseModel):
    """文件信息模型"""
    filename: str = Field(..., description="文件名")
    size: int = Field(..., description="文件大小(字节)")
    file_type: str = Field(..., description="文件类型")
    upload_time: str = Field(..., description="上传时间")

class UploadStats(BaseModel):
    """上传统计模型"""
    total_files: int = Field(..., description="总文件数")
    processed_files: int = Field(..., description="已处理文件数")
    failed_files: int = Field(..., description="失败文件数")
    processing_files: int = Field(0, description="正在处理文件数")
    total_size: int = Field(..., description="总文件大小(字节)")

class TaskListResponse(BaseModel):
    """任务列表响应模型"""
    total_tasks: int = Field(..., description="总任务数")
    tasks: Dict[str, Dict[str, Any]] = Field(..., description="任务详情") 